<template>
  <div>
    <ul>
      <li v-for="m in msg" :key="m.id">
        <a href="javascript:;">{{m.title}}</a>
        <button @click="pushShow(m)">push模式</button> 
        <button @click="replaceShow(m)">replace模式</button> 

      </li>
    </ul>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: "Message",
  data() {
    return {
      msg: [
        { id: "001", title: "测试message1" },
        {
          id: "002",
          title: "测试message2",
        },
        {
          id: "003",
          title: "测试message3",
        },
      ],
    };
  },
  methods: {
    pushShow(m) {
      this.$router.push({
        name: "xiangqin",
        query: {
          id: m.id,
          title: m.title,
        },
      });
    },
    replaceShow(m) {
      // console.log(this.$router);
      this.$router.replace({
        name: "xiangqin",
        query: {
          id: m.id,
          title: m.title,
        },
      });

    },
  },
   beforeDestroy() {
    console.log('message即将被销毁');
  }

};
</script>

<style>
</style>